package com.netflexitysolutions.amazonws.ec2.internal.operations;

import java.util.List;
import java.util.Set;

import com.amazonaws.ec2.doc._2009_04_04.RebootInstancesInfoType;
import com.amazonaws.ec2.doc._2009_04_04.RebootInstancesItemType;
import com.amazonaws.ec2.doc._2009_04_04.RebootInstancesType;
import com.netflexitysolutions.amazonws.ec2.EC2;

public class RebootInstancesOperation extends ObjectSetOperationExecutor<RebootInstancesType, Boolean> {

	public RebootInstancesOperation(EC2 ec2, Set<String> instanceIds) {
		super(ec2, instanceIds);
	}

	@Override
	protected Boolean call(RebootInstancesType request) {
		RebootInstancesInfoType set = new RebootInstancesInfoType();
		List<RebootInstancesItemType> list = set.getItem();
		for (String instanceId : objectIds) {
			RebootInstancesItemType item = new RebootInstancesItemType();
			item.setInstanceId(instanceId);
			list.add(item);
		}
		request.setInstancesSet(set);
		return getEC2().getService().rebootInstances(request).isReturn();
	}

}
